package com.hz.monitoring.module.hardware.dal.mysql.sensor_tenant_resource;

import com.hz.monitoring.framework.common.pojo.PageResult;
import com.hz.monitoring.framework.mybatis.core.mapper.BaseMapperX;
import com.hz.monitoring.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.hz.monitoring.module.hardware.controller.admin.sensor_tenant_resource.vo.SensorTenantResourceExportReqVO;
import com.hz.monitoring.module.hardware.controller.admin.sensor_tenant_resource.vo.SensorTenantResourceListReqVO;
import com.hz.monitoring.module.hardware.controller.admin.sensor_tenant_resource.vo.SensorTenantResourcePageReqVO;
import com.hz.monitoring.module.hardware.dal.dataobject.mcu_tenant_resource.McuTenantResourceDO;
import com.hz.monitoring.module.hardware.dal.dataobject.sensor_tenant_resource.SensorTenantResourceDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 传感器租户配置 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface SensorTenantResourceMapper extends BaseMapperX<SensorTenantResourceDO> {

    default PageResult<SensorTenantResourceDO> selectPage(SensorTenantResourcePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SensorTenantResourceDO>()
                .eqIfPresent(SensorTenantResourceDO::getMcuTenantResourceId, reqVO.getMcuTenantResourceId())
                .eqIfPresent(SensorTenantResourceDO::getMcuChannel,reqVO.getMcuChannel())
                .eqIfPresent(SensorTenantResourceDO::getModel, reqVO.getModel())
                .likeIfPresent(SensorTenantResourceDO::getName, reqVO.getName())
                .likeIfPresent(SensorTenantResourceDO::getRemark, reqVO.getRemark())
                .eqIfPresent(SensorTenantResourceDO::getTenantId,reqVO.getTenantId())
                .betweenIfPresent(SensorTenantResourceDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(SensorTenantResourceDO::getId));
    }

    default List<SensorTenantResourceDO> selectList(SensorTenantResourceListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<SensorTenantResourceDO>()
                .eqIfPresent(SensorTenantResourceDO::getMcuTenantResourceId, reqVO.getMcuTenantResourceId())
                .eqIfPresent(SensorTenantResourceDO::getMcuChannel,reqVO.getMcuChannel())
                .eqIfPresent(SensorTenantResourceDO::getModel, reqVO.getModel())
                .likeIfPresent(SensorTenantResourceDO::getName, reqVO.getName())
                .likeIfPresent(SensorTenantResourceDO::getRemark, reqVO.getRemark())
                .eqIfPresent(SensorTenantResourceDO::getTenantId,reqVO.getTenantId())
                .inIfPresent(SensorTenantResourceDO::getId,reqVO.getIds())
                .betweenIfPresent(SensorTenantResourceDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(SensorTenantResourceDO::getId));
    }

    default List<SensorTenantResourceDO> selectList(SensorTenantResourceExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<SensorTenantResourceDO>()
                .eqIfPresent(SensorTenantResourceDO::getMcuTenantResourceId, reqVO.getMcuTenantResourceId())
                .eqIfPresent(SensorTenantResourceDO::getModel, reqVO.getModel())
                .likeIfPresent(SensorTenantResourceDO::getName, reqVO.getName())
                .eqIfPresent(SensorTenantResourceDO::getRemark, reqVO.getRemark())
                .eqIfPresent(SensorTenantResourceDO::getTenantId,reqVO.getTenantId())
                .betweenIfPresent(SensorTenantResourceDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(SensorTenantResourceDO::getId));
    }

}
